/**
 * 用户选择框
 */
var userSelect = function() {
    var self = this;
    self.selectCB = null;
    self.user = null;

    self.init();
};
userSelect.prototype = {};

userSelect.prototype.init = function() {
    var self = this;
    $("#select_user .select a").click(function() {
        if (self.user) {
            self.selectCB(self.user);
            $("#select_user").modal('close');
        }
    });

    $("#select_user .filter .f2 button").click(function() {
        var v = $("#select_user .filter .f1 input").val();
        if (v == '') return;
        self.user = null;
        startLoading();
        CMD.find_user_by_name(v, function(r) {
            stopLoading();
            if (r.list.length == 0) {
                $("#select_user .info").html("<div class='empty'>用户不存在！</div>");
            }
            else {
                self.user = r.list[0];

                // 填充用户信息
            }
        });
    });
};

userSelect.prototype.show = function() {
    $("#select_user").modal({
        w: 500,
    });
}

window.UserSelect = new userSelect();